/**
*      author: Y_Yao
*      created: 2025-01-24 00:06:08
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 100 + 7;
int a[N][N],dp[N][N];
int f,v;

void print(int x,int y)
{
    if(x == 0 || y == 0) return;
    if(dp[x-1][y-1] + a[y][x] == dp[x][y])
    {
        print(x-1,y-1);
        cout << x << " ";
        return;
    }
    if(dp[x-1][y] == dp[x][y])
    {
        print(x-1,y);
    }
}

void solve()
{
    cin >> f >> v;
    memset(dp,-INF,sizeof dp);
    for(int i = 1;i <= f;i++)
    {
        for(int j = 1;j <= v;j++)
        {
            cin >> a[i][j];
        }
    }

    dp[0][0] = 0;
    for(int i = 1;i <= v;i++)
    {
        dp[i][1] = a[1][i];
        dp[i][0] = 0;
    }
    //第i个花瓶放第j朵花
    for(int i = 2;i <= v;i++)
    {
        for(int j = 1;j <= min(i,f);j++)
        {
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-1] + a[j][i]);
        }
    }

    cout << dp[v][f] << endl;
    print(v,f);
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}